home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / netz / term / extras / source / gtlayout-source.lha / LT_InitExit.c < prev    next >
C/C++ Source or Header  |  1995-03-25  |  2KB  |  128 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. BOOL __saveds __asm
  10. LT_Init()
  11. {
  12.     if(SysBase)
  13.         return(TRUE);
  14.     else
  15.     {
  16.         SysBase = *(struct ExecBase **)4;
  17.  
  18.         if(SysBase -> LibNode . lib_Version < 37)
  19.         {
  20.             SysBase = NULL;
  21.  
  22.             return(FALSE);
  23.         }
  24.         else
  25.         {
  26.             V39 = (SysBase -> LibNode . lib_Version >= 39);
  27.             V40 = (SysBase -> LibNode . lib_Version >= 40);
  28.  
  29.             IntuitionBase    = OpenLibrary("intuition.library",37);
  30.             GfxBase     = (struct GfxBase *)OpenLibrary("graphics.library",37);
  31.             UtilityBase    = OpenLibrary("utility.library",37);
  32.             GadToolsBase    = OpenLibrary("gadtools.library",37);
  33.             KeymapBase    = OpenLibrary("keymap.library",37);
  34.  
  35.             if(LocaleBase = (struct LocaleBase *)OpenLibrary("locale.library",38))
  36.                 LTP_Locale = OpenLocale(NULL);
  37.  
  38.             if(IntuitionBase && GfxBase && UtilityBase && GadToolsBase && KeymapBase)
  39.             {
  40.                 if(LTP_ImageClass = MakeClass(NULL,IMAGECLASS,NULL,sizeof(ImageInfo),0))
  41.                 {
  42.                     LTP_ImageClass -> cl_Dispatcher . h_Entry = (HOOKFUNC)LTP_ImageDispatch;
  43.  
  44. #ifdef DO_LEVEL_KIND
  45.                     if(LTP_LevelClass = MakeClass(NULL,IMAGECLASS,NULL,sizeof(LevelImageInfo),0))
  46.                     {
  47.                         LTP_LevelClass -> cl_Dispatcher . h_Entry = (HOOKFUNC)LTP_LevelClassDispatcher;
  48. #else
  49.                     {
  50. #endif    /* DO_LEVEL_KIND */
  51. #ifdef DO_PICKSHORTCUTS
  52.                         InitSemaphore(<P_KeySemaphore);
  53. #endif    /* DO_PICKSHORTCUTS */
  54.                         InitSemaphore(<P_LockSemaphore);
  55.  
  56.                         NewList((struct List *)<P_LockList);
  57.  
  58.                         return(TRUE);
  59.                     }
  60.                 }
  61.             }
  62.  
  63.             LT_Exit();
  64.  
  65.             return(FALSE);
  66.         }
  67.     }
  68. }
  69.  
  70.  
  71. /*****************************************************************************/
  72.  
  73.  
  74. VOID __saveds __asm
  75. LT_Exit()
  76. {
  77.     if(SysBase)
  78.     {
  79. #ifdef DO_LEVEL_KIND
  80.         if(LTP_LevelClass)
  81.         {
  82.             FreeClass(LTP_LevelClass);
  83.  
  84.             LTP_LevelClass = NULL;
  85.         }
  86. #endif    /* DO_LEVEL_KIND */
  87.         if(LTP_ImageClass)
  88.         {
  89.             FreeClass(LTP_ImageClass);
  90.  
  91.             LTP_ImageClass = NULL;
  92.         }
  93.  
  94.         if(LTP_Locale)
  95.         {
  96.             CloseLocale(LTP_Locale);
  97.  
  98.             LTP_Locale = NULL;
  99.         }
  100.  
  101.         CloseLibrary(LocaleBase);
  102.  
  103.         LocaleBase = NULL;
  104.  
  105.         CloseLibrary(KeymapBase);
  106.  
  107.         KeymapBase = NULL;
  108.  
  109.         CloseLibrary(GadToolsBase);
  110.  
  111.         GadToolsBase = NULL;
  112.  
  113.         CloseLibrary(UtilityBase);
  114.  
  115.         UtilityBase = NULL;
  116.  
  117.         CloseLibrary(GfxBase);
  118.  
  119.         GfxBase = NULL;
  120.  
  121.         CloseLibrary(IntuitionBase);
  122.  
  123.         IntuitionBase = NULL;
  124.  
  125.         SysBase = NULL;
  126.     }
  127. }
  128.